<?php

namespace app\controller;

use app\BaseController;
use mysqlversion\MysqlVersion;
use app\models\Sql;

class Api extends BaseController
{

    public function list()
    {
        try{
            $post = app()->request->post();
            $id   = $post['id'] ?? 0;
            $str  = $post['str'] ?? '';
            $sign = $post['sign'] ?? '';
            $mysqlVersion = new MysqlVersion();
            $sign = $mysqlVersion->client->verifySign($sign, $str);
            if(!$sign) {
                throw new \Exception('sign错误');
            }

            $list = Sql::where('id', '>', $id)
                ->page(1, 2)
                ->select()
                ->toArray();

            return json(['code' => 0, 'msg' => 'ok', 'data' => ['list' => $list]]);

        }catch (\Exception $e) {
            return json(['code' => 1, 'msg' => $e->getMessage(), 'data' => []]);
        }

    }


}
